<?php
/**
 * @version		$Id: genm.php $
 * @copyright	Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// No direct access
defined('_JEXEC') or die;

jimport('joomla.application.component.controllerform');

/**
 * Gen Model controller class.
 *
 * @package		Joomla.Administrator
 * @subpackage	com_gencode
 * @since		1.6
 */
class GenCodeControllerGenM extends JControllerForm
{
	/**
	 * @var		string	The prefix to use with controller messages.
	 * @since	1.6
	 */
	protected $text_prefix = 'COM_GENCODE_GENM';
	
	public function getConfig()
	{
		//require field type helper
		require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'fieldtype.config.php';
		
		//get type
		$fieldType 	= JRequest::getVar('field_type');
		$fieldName 	= JRequest::getVar('field_name');
		$genmId 	= JRequest::getVar('genm_id');
		$tableId 	= JRequest::getVar('table_id');
		
		$method = 'get'.$fieldType;
		
		$model = $this->getModel('GenM', 'GenCodeModel');
		$field = $model->getFormFields($genmId, $tableId, $fieldName);
		
		//get first rec
		if(!empty($field))
			$field = $field[0]->params;
		else 
			$field = serialize(array());
		
		$fieldTypeConfig = new FieldTypeConfigHelper($fieldName, $field);
		
		if(method_exists($fieldTypeConfig, $method))
			echo $fieldTypeConfig->$method();
		
		exit();
	}
}